import CommonHeader from '@/components/common-header/index'
import InstanceQuery from '@/apis/InstanceQuery'

import CancelEvection from '@/static/function-logo/cancel-evection.svg'
import CancelGoOut from '@/static/function-logo/cancel-go-out.svg'
import CancelVacate from '@/static/function-logo/cancel-vacate.svg'
import Certify from '@/static/function-logo/certify.svg'
import Dimission from '@/static/function-logo/dimission.svg'
import Evection from '@/static/function-logo/evection.svg'
import FillClock from '@/static/function-logo/fill-clock.svg'
import GoOut from '@/static/function-logo/go-out.svg'
import Overtime from '@/static/function-logo/overtime.svg'
import Regularization from '@/static/function-logo/regularization.svg'
import SalaryAdjustment from '@/static/function-logo/salary-adjustment.svg'
import TransferPosition from '@/static/function-logo/transfer-position.svg'
import Vacate from '@/static/function-logo/vacate.svg'
export default {
  name: '',
  components: {
    CommonHeader,
  },
  data() {
    return {
      selectStateList: [
        '待审批',
        '审批中',
        '已通过',
        '已驳回',
        '已撤销',
        '待销',
      ],
      destroyList: [],
    }
  },
  mounted() {
    // 查询我发起的
    InstanceQuery(
      {
        jobNumber: this.$store.state.userInfo.jobNumber, //工号
        processKey: '', //流程标识
        processState: this.selectStateList.indexOf('待销'), //审批状态
        processName: '',
        departmentName: this.$store.state.postInfo.department,
        procCurrNodeUserGroup: '', //当前节点负责人角色
        currentPage: 1,
        pageSize: 10,
      },
      this.$store.state.authorization
    ).then((res) => {
      // console.log('待销', res)
      this.destroyList = res.data.rows
    })
  },
  methods: {
    getId(id) {
      this.$store.commit('initDestroyId', id)
      uni.navigateBack({
        delta: 1,
      })
    },
    // 日期格式化
    formDate(date) {
      let year = new Date(date).getFullYear()
      let month =
        new Date(date).getMonth() + 1 < 10
          ? '0' + (new Date(date).getMonth() + 1)
          : new Date(date).getMonth()
      let day =
        new Date(date).getDate() < 10
          ? '0' + new Date(date).getDate()
          : new Date(date).getDate()
      let hours =
        new Date(date).getHours() < 10
          ? '0' + new Date(date).getHours()
          : new Date(date).getHours()
      let minutes =
        new Date(date).getMinutes() < 10
          ? '0' + new Date(date).getMinutes()
          : new Date(date).getMinutes()
      return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes
    },
    // IOS兼容问题
    formDateIOS(date) {
      return date ? date.split(':')[0] + ':' + date.split(':')[1] : ''
    },
    // logo选择器
    switchApprovalLogo(processName) {
      switch (processName) {
        case '销出差':
          return CancelEvection
          break
        case '请假':
          return Vacate
          break
        case '外出':
          return GoOut
          break
        case '销假':
          return CancelVacate
          break
        case '出差':
          return Evection
          break
        case '销外出':
          return CancelGoOut
          break
        case '加班':
          return Overtime
          break
        case '补卡':
          return FillClock
          break
        case '转正':
          return Regularization
          break
        case '调岗':
          return TransferPosition
          break
        case '离职':
          return Dimission
          break
        case '调薪':
          return SalaryAdjustment
          break
        case '报销':
          return Certify
          break
      }
    },
  },
}
